<?php
    $xtpl_list      = new XTemplate("view/product/list.htm");
    
    $heading    = $provider;
    $offset     = $_GET['p'];
    $limit      = 6;
    $offset     = (isset($offset) && ($offset > 0)) ? $offset : 0;
    
    $query          = "SELECT count(*) AS totalRecords FROM product WHERE provider='" . $provider . "'";
    $re             = mysql_query($query);
    $rows           = mysql_fetch_assoc($re);
    $totalRecords   = $rows['totalRecords'];

    $pages  = pagging($totalRecords, $offset, $limit, '?page=milk&module=' . $module);
    $sql    = "SELECT * FROM product WHERE provider='" . $provider . "' ORDER BY RAND() DESC LIMIT " . $offset . ", " . $limit . "";
    $result = mysql_query($sql);        
    while($row = mysql_fetch_array($result)){
        $xtpl_list  -> assign('id1', $row['id_p']);
        $xtpl_list  -> assign('id2', $row['id_p']);
        $xtpl_list  -> assign('image', $row['image']);
        $xtpl_list  -> assign('milkname', $row['milkname']);
        $xtpl_list  -> assign('cost', $row['cost']);
        $xtpl_list  -> assign('id3', $row['id_p']);
        $xtpl_list  -> insert_loop('LIST.TABLES', array('LIST'=>$row));
    }
    
    $xtpl_list  -> assign('pages', $pages);
    $xtpl_list  -> assign('heading', $heading);    
    $xtpl_list      -> parse("LIST");
    $mid            = $xtpl_list -> text("LIST");
?>